package com.woniuxy.carrental.service.impl;

import com.woniuxy.carrental.entity.User;
import com.woniuxy.carrental.mapper.UserMapper;
import com.woniuxy.carrental.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户servce的实现类
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    /*
    添加客户
     */
    @Override
    public void insertUser(User user) {
        userMapper.addUser(user);
    }

    /*
    查询黑名单或白名单
     */
    @Override
    public List<User> selectList(boolean uBlacklist) {
        List<User> users = userMapper.selectAllUsers(uBlacklist);

        return users;
    }

    /*
    分页查询
     */
    @Override
    public List<User> selectUserByPage(int pageIndex, int pageSize, User user) {

        List<User> users = userMapper.selectUserByPage(pageIndex, pageSize, user);

        return users;
    }

    /*
    查询总条数
     */
    @Override
    public int selectAllUserCount() {

        int i = userMapper.selectAllUserCount();
        return i;
    }

    /*
    拉入黑名单
   */
    @Override
    public void updateUserByBlack(Integer uid) {

        userMapper.updateUserByBlack(uid);
    }

    /*
    拉出黑名单
     */
    @Override
    public void updateUserByWhite(Integer uid) {

        userMapper.updateUserByWhite(uid);
    }

    /*
    根据id查询
     */
    @Override
    public User userByUid(Integer uid) {
        User user = userMapper.userByUid(uid);
        return user;
    }

    @Override
    public User getUserByPhone(String phone) {
        return userMapper.selectUserByPhone(phone);
    }

    /*
    修改客户
     */
    @Override
    public void updateUserAll(User user) {
        userMapper.updateUserAll(user);
    }
}
